import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '项目',
    align:"center",
    dataIndex: 'projectId_dictText'
   },
   {
    title: '系统',
    align:"center",
    dataIndex: 'projectSystem_dictText'
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'comments'
   },
   {
    title: '创建人',
    align:"center",
    dataIndex: 'createBy'
   },
   {
    title: '创建日期',
    align:"center",
    sorter: true,
    dataIndex: 'createTime'
   },
   {
    title: '更新人',
    align:"center",
    dataIndex: 'updateBy'
   },
   {
    title: '更新日期',
    align:"center",
    sorter: true,
    dataIndex: 'updateTime'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "项目",
      field: "projectId",
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"tm_project,project_name,id"
      },
      //colProps: {span: 6},
 	},
	{
      label: "系统",
      field: "projectSystem",
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"tm_project_system,system_name,id"
      },
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '项目',
    field: 'projectId',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"tm_project,project_name,id"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入项目!'},
          ];
     },
  },
  {
    label: '系统',
    field: 'projectSystem',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"tm_project_system,system_name,id"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入系统!'},
          ];
     },
  },
  {
    label: '备注',
    field: 'comments',
    component: 'InputTextArea',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
//子表表格配置
export const personDepartureItemColumns: JVxeColumn[] = [
    {
      title: '供应商',
      key: 'supplier',
      type: JVxeTypes.select,
      options:[],
      dictCode:"tm_supplier_manage,supplier_name,id",
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '离场人员',
      key: 'person',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '预计离场时间',
      key: 'departureTime',
      type: JVxeTypes.date,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '实际离场时间',
      key: 'actualDepartureTime',
      type: JVxeTypes.date,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '职位',
      key: 'position',
      type: JVxeTypes.select,
      options:[],
      dictCode:"tm_position,position_name,id",
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '级别',
      key: 'positionLevel',
      type: JVxeTypes.select,
      options:[],
      dictCode:"position_level",
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '人月数',
      key: 'personMothon',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
  ]

// 高级查询数据
export const superQuerySchema = {
  projectId: {title: '项目',order: 0,view: 'list', type: 'string',dictTable: "tm_project", dictCode: 'id', dictText: 'project_name',},
  projectSystem: {title: '系统',order: 1,view: 'list', type: 'string',dictTable: "tm_project_system", dictCode: 'id', dictText: 'system_name',},
  comments: {title: '备注',order: 2,view: 'textarea', type: 'string',},
  createBy: {title: '创建人',order: 3,view: 'text', type: 'string',},
  createTime: {title: '创建日期',order: 4,view: 'datetime', type: 'string',},
  updateBy: {title: '更新人',order: 5,view: 'text', type: 'string',},
  updateTime: {title: '更新日期',order: 6,view: 'datetime', type: 'string',},
  //子表高级查询
  personDepartureItem: {
    title: '离场人员',
    view: 'table',
    fields: {
        supplier: {title: '供应商',order: 0,view: 'list', type: 'string',dictTable: "tm_supplier_manage", dictCode: 'id', dictText: 'supplier_name',},
        person: {title: '离场人员',order: 1,view: 'text', type: 'string',},
        departureTime: {title: '预计离场时间',order: 2,view: 'date', type: 'string',},
        actualDepartureTime: {title: '实际离场时间',order: 3,view: 'date', type: 'string',},
        position: {title: '职位',order: 4,view: 'list', type: 'string',dictTable: "tm_position", dictCode: 'id', dictText: 'position_name',},
        positionLevel: {title: '级别',order: 5,view: 'list', type: 'string',dictCode: 'position_level',},
        personMothon: {title: '人月数',order: 6,view: 'number', type: 'number',},
    }
  },
};
